package com.nnfe.fyd.http;

import com.nnfe.fyd.bean.ChannelBean;
import com.nnfe.fyd.bean.HttpResult;
import com.nnfe.fyd.bean.SaveChannelBean;
import com.nnfe.fyd.bean.ad.AdBean;
import com.nnfe.fyd.bean.inquiry.AutoInquiry;
import com.nnfe.fyd.bean.inquiry.HousePrice;
import com.nnfe.fyd.bean.inquiry.RegionName;
import com.nnfe.fyd.bean.myinquirt.InquirtBean;
import com.nnfe.fyd.bean.registerAndLogin.LoginBean;
import com.nnfe.fyd.bean.registerAndLogin.RegisterBean;

import java.util.List;

import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * Created by Administrator on 2016/2/24.
 */
public interface RetrofitInterface<T> {


    /**
     * 经纪人注册
     *
     * @param captcha
     * @param name
     * @param mobile
     * @param password
     * @return
     */
    @FormUrlEncoded
    @POST("api/userCenter/rest/userInfo/save4Fyd")
    Call<HttpResult<RegisterBean>> doRegister(
            @Field("captcha") String captcha,
            @Field("name") String name,
            @Field("mobile") String mobile,
            @Field("password") String password,
            @Field("registChannel") String registChannel
    );


    /**
     * 经纪人登录
     *
     * @param loginName
     * @param password
     * @return
     */
    @FormUrlEncoded
    @POST("api/userCenter/rest/userLogin/fydLogin")
    Call<HttpResult<LoginBean>> doLogin(
            @Field("loginName") String loginName,
            @Field("password") String password
    );


    /**
     * 获取渠道列表
     *
     * @return
     */
    @GET("api/userCenter/rest/fyd/channel/findAll")
    Call<HttpResult<List<ChannelBean>>> getChannel();


    @GET("api/userCenter/rest/fyd/dealerext/save")
    Call<HttpResult<SaveChannelBean>> saveChannel(
            @Query("userId") String userId,
            @Query("wechat") String wechat,
            @Query("channelId") String channelId
    );

    /**
     * 上传用户头像
     *
     * @param userCenterId
     * @param file
     * @return
     */
    @Multipart
    @POST("api/userCenter/rest/userInfo/uploadHeadImg/{userCenterId}")
    Call<HttpResult<String>> uploadHeadImage(
            @Path("userCenterId") String userCenterId,
            @Part("file\"; filename=\"pp.png\" ") RequestBody file
    );

    /**
     * 获取用户头像
     *
     * @param userCenterId
     * @return
     */
    @GET("api/userCenter/rest/userInfo/getHeadImg/{userCenterId}")
    Call<HttpResult<String>> getHeadImg(
            @Path("userCenterId") String userCenterId,
            @Query("nnfetimes") String time
    );


    /**
     * 发送短信验证码
     *
     * @param moblie
     * @return
     */
    @FormUrlEncoded
    @POST("nnfeInterface/sms/sendCaptcha")
    Call<HttpResult> sendCaptcha(
            @Field("mobile") String moblie
    );


    /**
     * 重置密码
     *
     * @param mobile
     * @param captcha
     * @param password
     * @param repPwd
     * @return
     */
    @FormUrlEncoded
    @POST("api/userCenter/rest/userInfo/fydResetPwd")
    Call<HttpResult> resetPwd(
            @Field("mobile") String mobile,
            @Field("captcha") String captcha,
            @Field("password") String password,
            @Field("repPwd") String repPwd
    );

    /**
     * 询价列表
     *
     * @param page
     * @param count
     * @param userId
     * @return
     */
    @FormUrlEncoded
    @POST("api/userCenter/rest/fyd/inquiry/list/{page}/{count}")
    Call<HttpResult<InquirtBean>> inquiryList(
            @Path("page") String page,
            @Path("count") String count,
            @Field("userId") String userId
    );


    /**
     * 首页banner / 启屏广告
     *
     * @param type "1" 首页banner     "2" 启屏广告
     * @return
     */
    @POST("api/userCenter/rest/fyd/banner/findByType/{type}")
    Call<HttpResult<List<AdBean>>> findByType(
            @Path("type") String type
    );

    /**
     * 报单
     *
     * @return
     */
    @FormUrlEncoded
    @POST("/api/userCenter/rest/fyd/inquiry/inquiryReport/{id}")
    Call<HttpResult> inquiryReport(
            @Path("id") String id,
            @Field("customerName") String customerName,
            @Field("loanAmount") String loanAmount
    );

    /***
     * 模糊搜索小区
     *
     * @param userId
     * @param token
     * @param filter   // 搜索关键字
     * @return
     */
    @FormUrlEncoded
    @POST("fish/api/v3/fgg/getResidentialArea")
    Call<HttpResult<List<RegionName>>> autoSearchCommunity(
            @Field("userId") String userId,
            @Field("token") String token,
            @Field("filter") String filter
    );

    /**
     * 自动询价
     *
     * @param userId
     * @param token
     * @param areaName        // 小区名称   // 必选穿房咕咕的  residentialareaName
     * @param housingArea     // 居住面积
     * @param housingType     // 居住类型(住宅、别墅)
     * @param housingMortgage // 抵押情况
     * @param mortgageAmount  // 一低余额
     * @param userSource      // "app"
     * @return
     */
    @FormUrlEncoded
    @POST("api/userCenter/rest/fyd/inquiry/save4AutoInquiry")
    Call<HttpResult<AutoInquiry>> autoInquiry(
            @Field("userId") String userId,
            @Field("token") String token,
            @Field("roomAddress") String roomAddress,
            @Field("areaName") String areaName,
            @Field("housingArea") String housingArea,
            @Field("housingType") String housingType,
            @Field("housingMortgage") String housingMortgage,
            @Field("mortgageAmount") String mortgageAmount,
            @Field("userSource") String userSource
    );

    /**
     * 调用房咕咕接口，进行询价
     * @param houseType // 住宅类型（住宅、别墅 ）
     * @param area      // 建筑面积（111.22）
     * @param filter    // 查询条件 必须为查询小区返回的residentialareaName值
     * @return
     */
    @FormUrlEncoded
    @POST("fish/api/v3/fgg/getInquiry")
    Call<HttpResult<HousePrice>> getInquiry(
            @Field("userId") String userId,
            @Field("token") String token,
            @Field("houseType") String houseType,
            @Field("area") String area,
            @Field("filter") String filter
    );


    /**
     *  检验token是否有效
     *
     * @param userId
     * @return
     */
    @FormUrlEncoded
    @POST("api/userCenter/rest/fyd/fydLoginCtrl/{userId}/checkToken")
    Call<HttpResult<Boolean>> checkToken(
            @Path("userId") String userId,
            @Field("token") String token
    );

}